package distributedbank.server.messages;

import java.io.IOException;

import distributedbank.Wrapper;
import distributedbank.server.BankBranch;

/**
 * Request for a SyncRequest, used only by the new primary
 * 
 * @author Bill
 */
public class HistoryRequest
        extends Transaction {
    private static final long serialVersionUID = 1L;

    public HistoryRequest(int branchId, int fromPort) {
        super(branchId, 0, -1, fromPort);
    }

    @Override
    public void runRequest(BankBranch bankBranch, Wrapper wrapper)
            throws IOException {
        HistoryResponse response = new HistoryResponse(bankBranch.accounts);
        response.fromPort = wrapper.localPort;
        wrapper.sendAcknowledgment(response, this.fromPort);
    }

    @Override
    public Acknowledgment runRequestSilent(BankBranch bankBranch) {
        return null;
    }
}
